home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* */
- /* Module: POKEY Chip Simulator Includes, V1.1 */
- /* Purpose: To emulate the sound generation hardware of the Atari POKEY chip.*/
- /* Author: Ron Fries */
- /* Date: September 22, 1996 */
- /* */
- /*****************************************************************************/
- /* */
- /* License Information and Copyright Notice */
- /* ======================================== */
- /* */
- /* PokeySound is Copyright(c) 1996 by Ron Fries */
- /* */
- /* This library is free software; you can redistribute it and/or modify it */
- /* under the terms of version 2 of the GNU Library General Public License */
- /* as published by the Free Software Foundation. */
- /* */
- /* This library is distributed in the hope that it will be useful, but */
- /* WITHOUT ANY WARRANTY; without even the implied warranty of */
- /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library */
- /* General Public License for more details. */
- /* To obtain a copy of the GNU Library General Public License, write to the */
- /* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
- /* */
- /* Any permitted reproduction of these routines, in whole or in part, must */
- /* bear this legend. */
- /* */
- /*****************************************************************************/
-
- #ifndef __POKEY__
- #define __POKEY__
-
- #include "atari.h"
-
- /* define some data types to keep it platform independent */
- #ifdef COMP16 /* if 16-bit compiler defined */
- #define int8 char
- #define int16 int
- #define int32 long
- #else /* else default to 32-bit compiler */
- #define int8 char
- #define int16 short
- #define int32 int
- #endif
-
- #define uint8 unsigned int8
- #define uint16 unsigned int16
- #define uint32 unsigned int32
-
-
- /* CONSTANT DEFINITIONS */
-
- /* As an alternative to using the exact frequencies, selecting a playback
- frequency that is an exact division of the main clock provides a higher
- quality output due to less aliasing. For best results, a value of
- 1787520 MHz is used for the main clock. With this value, both the
- 64 kHz and 15 kHz clocks are evenly divisible. Selecting a playback
- frequency that is also a division of the clock provides the best
- results. The best options are FREQ_64 divided by either 2, 3, or 4.
- The best selection is based on a trade off between performance and
- sound quality.
-
- Of course, using a main clock frequency that is not exact will affect
- the pitch of the output. With these numbers, the pitch will be low
- by 0.127%. (More than likely, an actual unit will vary by this much!) */
-
- #define FREQ_17_EXACT 1789790 /* exact 1.79 MHz clock freq */
- #define FREQ_17_APPROX 1787520 /* approximate 1.79 MHz clock freq */
-
- void Pokey_sound_init (ULONG freq17, UWORD playback_freq);
- void Pokey_process_2 (register unsigned char *buffer, register UWORD n);
- void Pokey_process (register unsigned char *buffer, register UWORD n);
- void POKEY_Scanline(void);
- void SendKey(UBYTE key);
- void SendBRK(void);
-
- extern ULONG Div_n_cnt[4], /* Divide by n counter. one for each channel */
- Div_n_max[4], /* Divide by n maximum, one for each channel */
- Div_n_irq[4]; /* Just the same counter, but used for IRQ */
-
- extern int DELAYED_SERIN_IRQ;
- extern int DELAYED_SEROUT_IRQ;
- extern int DELAYED_XMTDONE_IRQ;
-
- #define _AUDF1 0x00
- #define _AUDC1 0x01
- #define _AUDF2 0x02
- #define _AUDC2 0x03
- #define _AUDF3 0x04
- #define _AUDC3 0x05
- #define _AUDF4 0x06
- #define _AUDC4 0x07
- #define _AUDCTL 0x08
- #define _STIMER 0x09
- #define _SKRES 0x0a
- #define _POTGO 0x0b
- #define _SEROUT 0x0d
- #define _IRQEN 0x0e
- #define _SKCTLS 0x0f
-
- #define _POT0 0x00
- #define _POT1 0x01
- #define _POT2 0x02
- #define _POT3 0x03
- #define _POT4 0x04
- #define _POT5 0x05
- #define _POT6 0x06
- #define _POT7 0x07
- #define _ALLPOT 0x08
- #define _KBCODE 0x09
- #define _RANDOM 0x0a
- #define _SERIN 0x0d
- #define _IRQST 0x0e
- #define _SKSTAT 0x0f
-
- extern UBYTE KBCODE;
- extern UBYTE IRQST;
- extern UBYTE IRQEN;
- extern UBYTE SKSTAT;
-
- /* channel definitions */
- #define CHAN1 0
- #define CHAN2 1
- #define CHAN3 2
- #define CHAN4 3
- #define SAMPLE 4
-
- UBYTE AUDF[4]; /* AUDFx (D200, D202, D204, D206) */
- UBYTE AUDC[4]; /* AUDCx (D201, D203, D205, D207) */
- UBYTE AUDCTL; /* AUDCTL (D208) */
-
- void Init_Pokey (int *argc, char *argv[],int base);
- #endif
-